#[doc = r"Enumeration of all the interrupts."]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum Interrupt {
    #[doc = "38 - UART0 interrupt"]
    UART0 = 38,
    #[doc = "39 - UART1 interrupt"]
    UART1 = 39,
    #[doc = "40 - UART2 interrupt"]
    UART2 = 40,
    #[doc = "41 - I2C0 interrupt"]
    I2C0 = 41,
    #[doc = "42 - I2C1 interrupt"]
    I2C1 = 42,
    #[doc = "43 - SPI0 interrupt"]
    SPI0 = 43,
    #[doc = "44 - SPI1 interrupt"]
    SPI1 = 44,
    #[doc = "45 - GPIO interrupt"]
    GPIO = 45,
    #[doc = "46 - T-Sensor interrupt interrupt"]
    TSENSOR = 46,
    #[doc = "51 - Software interrupt 0"]
    SOFT0 = 51,
    #[doc = "52 - Software interrupt 1"]
    SOFT1 = 52,
    #[doc = "53 - Software interrupt 2"]
    SOFT2 = 53,
    #[doc = "54 - Software interrupt 3"]
    SOFT3 = 54,
    #[doc = "59 - I2S0 interrupt"]
    I2S0 = 59,
}
#[derive(Debug, Copy, Clone)]
pub struct TryFromInterruptError(());
impl Interrupt {
    #[inline]
    pub fn try_from(value: u8) -> Result<Self, TryFromInterruptError> {
        match value {
            38 => Ok(Interrupt::UART0),
            39 => Ok(Interrupt::UART1),
            40 => Ok(Interrupt::UART2),
            41 => Ok(Interrupt::I2C0),
            42 => Ok(Interrupt::I2C1),
            43 => Ok(Interrupt::SPI0),
            44 => Ok(Interrupt::SPI1),
            45 => Ok(Interrupt::GPIO),
            46 => Ok(Interrupt::TSENSOR),
            51 => Ok(Interrupt::SOFT0),
            52 => Ok(Interrupt::SOFT1),
            53 => Ok(Interrupt::SOFT2),
            54 => Ok(Interrupt::SOFT3),
            59 => Ok(Interrupt::I2S0),
            _ => Err(TryFromInterruptError(())),
        }
    }
}
#[cfg(feature = "rt")]
#[macro_export]
#[doc = r" Assigns a handler to an interrupt"]
#[doc = r""]
#[doc = r" This macro takes two arguments: the name of an interrupt and the path to the"]
#[doc = r" function that will be used as the handler of that interrupt. That function"]
#[doc = r" must have signature `fn()`."]
#[doc = r""]
#[doc = r" Optionally, a third argument may be used to declare interrupt local data."]
#[doc = r" The handler will have exclusive access to these *local* variables on each"]
#[doc = r" invocation. If the third argument is used then the signature of the handler"]
#[doc = r" function must be `fn(&mut $NAME::Locals)` where `$NAME` is the first argument"]
#[doc = r" passed to the macro."]
#[doc = r""]
#[doc = r" # Example"]
#[doc = r""]
#[doc = r" ``` ignore"]
#[doc = r" interrupt!(TIM2, periodic);"]
#[doc = r""]
#[doc = r" fn periodic() {"]
#[doc = r#"     print!(".");"#]
#[doc = r" }"]
#[doc = r""]
#[doc = r" interrupt!(TIM3, tick, locals: {"]
#[doc = r"     tick: bool = false;"]
#[doc = r" });"]
#[doc = r""]
#[doc = r" fn tick(locals: &mut TIM3::Locals) {"]
#[doc = r"     locals.tick = !locals.tick;"]
#[doc = r""]
#[doc = r"     if locals.tick {"]
#[doc = r#"         println!("Tick");"#]
#[doc = r"     } else {"]
#[doc = r#"         println!("Tock");"#]
#[doc = r"     }"]
#[doc = r" }"]
#[doc = r" ```"]
macro_rules ! interrupt { ( $ NAME : ident , $ path : path , locals : { $ ( $ lvar : ident : $ lty : ty = $ lval : expr ; ) * } ) => { # [ allow ( non_snake_case ) ] mod $ NAME { pub struct Locals { $ ( pub $ lvar : $ lty , ) * } } # [ allow ( non_snake_case ) ] # [ no_mangle ] pub extern "C" fn $ NAME ( ) { let _ = $ crate :: interrupt :: Interrupt :: $ NAME ; static mut LOCALS : self :: $ NAME :: Locals = self :: $ NAME :: Locals { $ ( $ lvar : $ lval , ) * } ; let f : fn ( & mut self :: $ NAME :: Locals ) = $ path ; f ( unsafe { & mut LOCALS } ) ; } } ; ( $ NAME : ident , $ path : path ) => { # [ allow ( non_snake_case ) ] # [ no_mangle ] pub extern "C" fn $ NAME ( ) { let _ = $ crate :: interrupt :: Interrupt :: $ NAME ; let f : fn ( ) = $ path ; f ( ) ; } } }
